define(function (require, exports, module) {
    var indexTemp = require("text!../template/index.html");
    var DraggableMenu = require("draggableMenu"); //
    require("swiper");
    module.exports = Nuui.View.extend({
        template: indexTemp,

        onRender: function () {
        	var view=this;
            var index = 0;
            setInterval(play, 3000);
            function play() {
                index++;
                if (index > 5) {
                    index = 0
                }
                $(".banner img ").eq(index).fadeIn().siblings().fadeOut();
            }
            
            App.request(App.server.getServePath(App.path.smartGroupAction),{
            	success:function(data){
            		if(data.ec){
						alert(data.em);						
					}else{
						var res=data.smartGroupList.IndustryExperts.list;
						for(var i=0;i<res.length;i++){
							var html='';
							html+='';
							html+='<dl data-id='+res[i].id+'>';
							html+='	<dt><img src="images/img/'+res[i].avatar+'"/></dt>';
							html+='	<dd>'+res[i].name+'</dd>';
							html+='</dl>';
							view.$('.homepage2-section3 .expert').append(html);
						}
						App.storage.set('smartGroupMenuCode','IndustryExperts');
					}
            	}
            })

        },

        onShow: function () {
        	var view=this;
            var mySwiper = new Swiper ('.swiper-container', {
                direction: 'horizontal',
                loop: true,
                autoplay : 2500,
                pagination: '.swiper-pagination'
            });

            var ul2 = $(".swiper-wrapper>div");
            ul2.on("tap", function(){
                index = $(this).index()-1;
                sessionStorage.setItem("key", index);
                App.navigate("example/index/productService", true);
                return false;
            });


            var ul1 = $(".ul1>li");
            ul1.on("tap", function(){
                index = $(this).index();
                sessionStorage.setItem("key", index)
                App.navigate("example/index/productService", true);
                return false;
            });

        	var view=this;
        	view.$(".homepage2-section3 .expertPage").on("tap",function(){
 				App.navigate("example/index/smartgroup",true)
        		return false;
        	})/*
        	view.$(".homepage2-section4 .yun").on("tap","li",function(){
				var targetCode=$(this).attr('data-code');
 				App.storage.set('yunBrandCode',targetCode);
 				App.navigate("example/index/partnersDetail",true);
        		return false;
        	})*/
        	//云产品列表
        	view.$(' .homepage2-section1 dl').on('tap', function(){
				var self = $(this);
				var targetCode=$(this).attr('class').trim();
 				App.storage.set('productCode',targetCode);
 				App.storage.set('productName',$(this).find('dd').text().trim());
				App.navigate("example/index/cloudprocurement",true);
				return false;
			});
        	//行业专家
        	view.$(' .homepage2-section3 .expert').on('tap','dl', function(){
        		var e=e||event;
				var elm=e.target||e.srcElement;
				var targetId=$(this).attr('data-id');
 				App.storage.set('smartGroupListId',targetId);
				App.navigate("example/index/thinktankdetails", true);
						return false;
			});
        	
        	
        	/*搜索框*/

			$('#homepage2-header').on('tap','.search',function(){
				App.navigate("example/index/search", true);
				return false;
			})
			
			/*侧滑页*/
			$('.cate_btn').on('tap',function(){
				$('.slide-page').addClass('active');
				$('.import-page').css('display','none');
			})
			$('.slide-page .back').on('tap',function(){
				$('.slide-page').removeClass('active');
				$('.import-page').css('display','block');
				
			})
			
			/*侧滑页tab切换*/
			view.$('.slide-page').on('tap','.cate-list .item',function(){
				var index=$(this).index();
				var cateName=$(this).text().trim();
				$(this).addClass('active').siblings().removeClass('active');
				$('.cate-content-box .item').eq(index).addClass('active').siblings().removeClass('active');
				$('.part-right .cate-title').text(cateName);
			})
        }
    });
});
